package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonPage;
import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.ProductLibraryRequest;
import com.ytjj.qmyx.admin.model.request.ProductSelectRequest;
import com.ytjj.qmyx.admin.model.response.ProductLibraryResponse;
import com.ytjj.qmyx.admin.service.ProductLibraryService;
import com.ytjj.qmyx.mall.model.ProductLibrary;
import com.ytjj.qmyx.mall.model.ProductSelect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 供应商产品库
 */
@RestController
@RequestMapping("/productLibrary")
public class ProductLibraryController {
    @Autowired
    private ProductLibraryService productLibraryService;

    /**
     * 产品库列表
     * @param productLibraryRequest
     * @return
     */
    @PostMapping("/selectList")
    public CommonResult selectList(@RequestBody ProductLibraryRequest productLibraryRequest){
        CommonPage<ProductLibraryResponse> pageList = productLibraryService.selectList(productLibraryRequest);
        return CommonResult.success(pageList);
    }
    /**
     * 添加选品商品
     */
    @PostMapping("/insertProductSelect")
    @OperLog(operModule = "商品库模块", operDesc = "新增选品商品", operType = SysLogConstants.OPERATION_ADD)
    public CommonResult insertProductSelect(@RequestBody ProductLibrary productLibrary){
        int count = productLibraryService.insertProductSelect(productLibrary);
        if (count > 0){
            return CommonResult.success(count);
        }else {
            return CommonResult.failed();
        }
    }
}
